library(stm)

##########################################################
##Full Text Translation Replication: Running the Models###
##########################################################

#Read in tdms
load("Prepped.Translated.Docs.RData")

#Run models

set.seed(02138)

translated.docs <- prepped.translated.docs$documents
translated.docs.vocab <- prepped.translated.docs$vocab
translated.docs.meta <- prepped.translated.docs$meta


runs<-50
translated.docs.mod.10 <- selectModel(translated.docs,
                                      translated.docs.vocab,
                                      K=10,runs=runs,
                                      prevalence
                                      =~ Language +
                                      s(Date),content=~Language,
                                      max.em.its = 100,
                                      data= translated.docs.meta,
                                      seed= 02138)

translated.docs.mod.15 <- selectModel(translated.docs,
                                      translated.docs.vocab,
                                      K=15,runs=runs,
                                      prevalence
                                      =~ Language +
                                      s(Date),content=~Language,
                                      max.em.its = 100,data
                                      = translated.docs.meta, seed
                                      = 02138)

#save(translated.docs,
#     translated.docs.vocab,translated.docs.meta,translated.docs.mod.10,translated.docs.mod.15,file="SnowdenC-noRT.RData")  

translated.docs.mod.10 <- selectModel(translated.docs,
                                      translated.docs.vocab,
                                      K=10,runs=runs,
                                      prevalence
                                      =~ Language +
                                      s(Date),
                                      max.em.its = 100,
                                      data= translated.docs.meta,
                                      seed= 02138)

translated.docs.mod.15 <- selectModel(translated.docs,
                                      translated.docs.vocab,
                                      K=15,runs=runs,
                                      prevalence
                                      =~ Language +
                                      s(Date),
                                      max.em.its = 100,data
                                      = translated.docs.meta, seed
                                      = 02138)

#save(translated.docs,
#     translated.docs.vocab,translated.docs.meta,translated.docs.mod.10,translated.docs.mod.15,file="SnowdennoC-noRT.RData")  


##########################################################
##Term-by-Term Translation Replication: Running the Models###
##########################################################

load("Prepped.Translated.Docs_TermByTerm.RData")

set.seed(02138)

translated.docs <- prepped.translated.docs$documents
translated.docs.vocab <- prepped.translated.docs$vocab
translated.docs.meta <- prepped.translated.docs$meta


runs<-50
translated.docs.mod.10 <- selectModel(translated.docs,
                                      translated.docs.vocab,
                                      K=10,runs=runs,
                                      prevalence
                                      =~ OriginalLanguage +
                                      s(Date),content=~OriginalLanguage,
                                      max.em.its = 100,
                                      data= translated.docs.meta,
                                      seed= 02138)

translated.docs.mod.15 <- selectModel(translated.docs,
                                      translated.docs.vocab,
                                      K=15,runs=runs,
                                      prevalence
                                      =~ OriginalLanguage +
                                      s(Date),content=~OriginalLanguage,
                                      max.em.its = 100,data
                                      = translated.docs.meta, seed
                                      = 02138)

#save(translated.docs,
#     translated.docs.vocab,translated.docs.meta,translated.docs.mod.10,translated.docs.mod.15,file="SnowdenC-noRT-TermByTerm.RData")  
